package engine.gameObject.terrain;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class TerrainLoader {

	private TerrainLoader() {}
	
	public static Terrain loadRAW(String file, int size, float scale, int detailAreaSize) {
		try {
			DataInputStream input = new DataInputStream(new FileInputStream(file));
			
			float[][] height = new float[size][size];
			
			for(int i = 0; i < size; i++) {
				for(int j = 0; j < size; j++) {
					height[i][j] = input.readUnsignedByte() * scale;
				}
			}
			
			input.close();
			
			return new Terrain(height, detailAreaSize);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return null;
	}
}
